<?php

namespace app\bis\controller;

use think\Controller;
use think\Request;

class Base extends Controller
{
    public $account;

    public function _initialize()
    {
        $isLogin = $this->is_login();
        if (!$isLogin) {
            $this->redirect(url('login/index'));
        }
    }

    //判断是否登录
    public function is_login()
    {
        $user = $this->getLoginUser();
        if ($user && $user->id) {
            return true;
        }
        return false;
    }

    //获取session值
    public function getLoginUser()
    {
        if (!$this->account) {
            //判断用户是否登录
            return $this->account = session('account', '', 'bis');
        }
        return $this->account;
    }
}
